package com.visualize.demo.service;

import com.visualize.demo.model.JsonResponse;
import com.visualize.demo.model.Source;
import com.visualize.demo.repository.SourceRepository;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service
public class SourceService extends BaseService {
    private final SourceRepository sourceRepository;

    public SourceService(SourceRepository sourceRepository) {
        this.sourceRepository = sourceRepository;
    }

    public JsonResponse getData(String sTime, String eTime) {
        List<Source> sourceList = sourceRepository.getSourceListByTime(parseDate(sTime), parseDate(eTime));
        Map<String, List<Source>> content = new HashMap<>();
        content.put("list", sourceList);
        return new JsonResponse(200, content);
    }
}
